package org.common.service.mongo;

import org.common.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.common.repository.UserRepository;

import java.util.List;


@Service
public class UserService {

    @Autowired
    private UserRepository userRepository;

    public UserEntity getUserById(String id) {
        return userRepository.findById(id).orElse(null);
    }


    public List<UserEntity> getUserByUsername(String username) {
        return userRepository.findByUsername(username);
    }


    public List<UserEntity> findByUsernameAndPassword(String username, String password) {
        return userRepository.findByUsernameAndPassword(username, password);
    }


    public UserEntity saveUser(UserEntity entity) {
        return userRepository.save(entity);
    }
}
